package com.zut.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zut.mapper.ManagerMapper;
import com.zut.pojo.Manager;
import com.zut.pojo.Result;
import com.zut.service.ManagerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: Mr.Liu
 * @create: 2021-11-13 17:33
 */
@RestController
@RequestMapping("/manager")
public class ManagerController {

    @Autowired
    ManagerService managerService;

    @Autowired
    ManagerMapper managerMapper;

    @ApiOperation("获取所有用户")
    @GetMapping("/all/{current}")
    public Result getAllManager(@PathVariable Integer current){
        return managerService.getAllManager(current);
    }

    @ApiOperation("升级权限")
    @PostMapping("/roles")
    public Result updateUserRoles(Integer id){
        return managerService.updateUserRoles(id);
    }

    @ApiOperation("根据用户名查找用户")
    @PostMapping("/select")
    public List<Manager> selectByUsername(String username){
        return managerMapper.selectList(new QueryWrapper<Manager>().like(true,"username",username)
                .eq("auths","user"));
    }
}
